package com.stylefeng.guns.config;

import org.quartz.SchedulerException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;

/**
 * Created by lyz on 2018/1/20.
 */
@Configuration
@EnableScheduling
@Component
public class TimerConfig implements InitializingBean {


    @Override
    public void afterPropertiesSet() throws Exception {
    }

    @Scheduled(cron = "0 0 6 * * ?")
    public void schedule() throws SchedulerException {
    }

    @Bean
    public SchedulerFactoryBean schedulerFactoryBean() {
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        return schedulerFactoryBean;
    }
}
